-- Decompiled with the Synapse X Luau decompiler.

local l__CommonOHOH__1 = _G.CommonOHOH;
local v2 = {};
local u1 = {};
local u2 = {};
function u1.ShowMark(p1, p2)
	u1.CleanMark(p1);
	for v3, v4 in ipairs(p2) do
		local v5, v6 = next(u2);
		if not v5 then
			v6 = Instance.new("Part");
			v6.Shape = Enum.PartType.Ball;
			v6.Anchored = true;
			v6.CanCollide = false;
			v6.CanTouch = false;
			v6.Size = Vector3.new(1, 1, 1);
		else
			table.remove(u2, v5);
		end;
		v6.Parent = workspace;
		v6.Position = v4.Position;
		p1.marks[v6] = true;
	end;
end;
function u1.CleanMark(p3)
	for v7, v8 in pairs(p3.marks) do
		table.insert(u2, v7);
		v7.Parent = nil;
		p3.marks[v7] = nil;
	end;
end;
function u1.FindPath(p4, p5)
	while p4.target_pos do
		local l__humanoid__9 = p4.humanoid;
		if l__humanoid__9 then
			local v10 = l__humanoid__9:GetState();
			if v10 ~= Enum.HumanoidStateType.Jumping and v10 ~= Enum.HumanoidStateType.Ragdoll and v10 ~= Enum.HumanoidStateType.FallingDown and v10 ~= Enum.HumanoidStateType.Freefall then
				local l__path__11 = p4.path;
				p4.target_pos = nil;
				p4:WaitForFunc(l__path__11.ComputeAsync, l__path__11, p4.parent:GetPosition(), p4.target_pos);
				if l__path__11.Status ~= Enum.PathStatus.Success then
					p4.points = nil;
					u1.CleanMark(p4);
				else
					p4.points = l__path__11:GetWaypoints();
					if p4.points[1].Action == Enum.PathWaypointAction.Jump then
						l__humanoid__9.Jump = true;
					end;
					p4.index = 1;
					if p5 then
						l__humanoid__9:MoveTo(p4.parent:GetPosition());
						u1.ShowMark(p4, p4.points);
					end;
				end;
				if p4.__update_co then
					p4.__update_co = nil;
					coroutine.resume(p4.__update_co, p4.points);
				end;
			else
				p4:Wait();
			end;
		end;	
	end;
	p4.__find_path_cnnt = nil;
end;
function u1.Update(p6)
	while true do
		if p6.__find_path_cnnt then
			if not p6.points or not p6.index or #p6.points < p6.index then
				p6.__update_co = coroutine.running();
				if not coroutine.yield() then
					break;
				end;
			end;
		else
			if not p6.points then
				break;
			end;
			if not p6.index then
				break;
			end;
			if #p6.points < p6.index then
				break;
			end;
		end;
		p6.index = p6.index + 1;
		local v12 = p6.points[p6.index];
		local l__humanoid__13 = p6.humanoid;
		if not l__humanoid__13 then
			break;
		end;
		if v12 then
			if v12.Action == Enum.PathWaypointAction.Jump then
				l__humanoid__13.Jump = true;
				p6:Wait();
			end;
			p6.__move_to = true;
			p6.__move_failed = 0;
			l__humanoid__13:MoveTo(v12.Position);
			if not p6:WaitForFunc(l__humanoid__13.MoveToFinished.Wait, l__humanoid__13.MoveToFinished) then
				p6.__move_to = false;
				break;
			end;
			p6.__move_to = false;
		else
			p6.points = nil;
			p6.index = nil;
		end;	
	end;
	p6.__update_co = nil;
	p6.points = nil;
	p6.index = nil;
	p6.__update_cnnt = nil;
	for v14, v15 in pairs(p6.__on_move_over_handle) do
		p6:AddProcess(v14, table.unpack(v15));
	end;
end;
function u1.AddHandleOnMoveOver(p7, p8, ...)
	assert(p8, "param handle is nil");
	p7.__on_move_over_handle[p8] = { ... };
end;
function u1.DelhandleOnMoveOver(p9, p10)
	assert(p10, "param handle is nil");
	p9.__on_move_over_handle[p10] = nil;
end;
function u1.OnMoveOverHandleExist(p11, p12)
	assert(p12, "param handle is nil");
	return p11.__on_move_over_handle[p12];
end;
function u1.CheckStop(p13, p14)
	if p13.points and #p13.points <= p13.index then
		return;
	end;
	if p13.__move_to and p14 == 0 then
		p13.__move_failed = p13.__move_failed + 1;
		if p13.__move_failed < 3 and p13.params.AgentCanJump ~= nil and p13.params.AgentCanJump == true then
			local l__humanoid__16 = p13.humanoid;
			if l__humanoid__16 then
				l__humanoid__16.Jump = true;
				return;
			else
				p13.__move_failed = 0;
				p13:StopMove();
				return;
			end;
		else
			p13.__move_failed = 0;
			p13:StopMove();
		end;
	end;
end;
local M = l__CommonOHOH__1.class.new(script, l__CommonOHOH__1.files.BaseComponent());
function M.new(p15)
	return M(p15);
end;
local l__PathfindingService__4 = game:GetService("PathfindingService");
local u5 = l__CommonOHOH__1.load.CallBackManager();
function M.ctor(p16, p17)
	M.super.ctor(p16, p17);
	p16.marks = {};
	p16.__on_move_over_handle = {};
	p16.__move_failed = 0;
	p16.humanoid = p17:GetHumanoid_Check();
	p16.root_part = p17:GetRootPart_Check();
	local l__Size__17 = p17:GetRootPart_Check().Size;
	p16.params = {
		AgentRadius = l__Size__17.X, 
		AgentHeight = l__Size__17.Y + p16.humanoid.HipHeight, 
		AgentCanJump = true
	};
	p16.path = l__PathfindingService__4:CreatePath(p16.params);
	p16.check_path = l__PathfindingService__4:CreatePath(p16.params);
	u5:AddRbxConnect(p16, p16.humanoid.Running, u1.CheckStop);
end;
function M.SetCharacterHegiht(p18, p19)
	p18.params.AgentHeight = p19 or p18.parent:GetExtentsSize().Y;
	p18.path = l__PathfindingService__4:CreatePath(p18.params);
	p18.check_path = l__PathfindingService__4:CreatePath(p18.params);
end;
function M.SetCharacterRadius(p20, p21)
	p20.params.AgentRadius = p21 or p20.parent:GetExtentsSize().X;
	p20.path = l__PathfindingService__4:CreatePath(p20.params);
	p20.check_path = l__PathfindingService__4:CreatePath(p20.params);
end;
function M.SetCharacterCanJump(p22, p23)
	if p23 == nil then
		p23 = false;
	end;
	p22.params.AgentCanJump = p23;
	p22.path = l__PathfindingService__4:CreatePath(p22.params);
end;
function M.dtor(p24)
	u1.CleanMark(p24);
	M.super.dtor(p24);
end;
function M.MoveTo(self, p26, p27)
	if self.target_pos and (self.target_pos - p26).Magnitude <= 0.5 then
		return;
	end;
	if not self:IsExist() then
		return;
	end;
	self.target_pos = p26;
	if not self.__find_path_cnnt then
		self.__find_path_cnnt = self:AddProcess(u1.FindPath, p27);
	end;
	if not self.__update_cnnt then
		self.__update_cnnt = self:AddProcess(u1.Update);
	end;
end;
function M.GetPathLenght(p28, p29)
	assert(p29, "param pos is nil");
	if not p28.parent.main_inst then
		return -1;
	end;
	local l__check_path__18 = p28.check_path;
	l__check_path__18:ComputeAsync(p28.parent:GetPosition(), p29);
	if l__check_path__18.Status ~= Enum.PathStatus.Success then
		return -1;
	end;
	local v19 = 0;
	local v20 = l__check_path__18:GetWaypoints();
	for v21 = 2, #v20 do
		local v22 = v20[v21 - 1];
		local v23 = v20[v21];
		if not v23 then
			break;
		end;
		if not v22 then
			break;
		end;
		v19 = v19 + (v23.Position - v22.Position).Magnitude;
	end;
	if v19 ~= 0 then
		return v19;
	end;
	return -1;
end;
function M.StopMove(p30)
	if p30.__find_path_cnnt then
		p30.__find_path_cnnt:Disconnect();
		p30.__find_path_cnnt = nil;
	end;
	if p30.__update_cnnt then
		p30.__update_cnnt:Disconnect();
		p30.__update_cnnt = nil;
	end;
	local l__parent__24 = p30.parent;
	local l__humanoid__25 = p30.humanoid;
	local l__root_part__26 = p30.root_part;
	if l__humanoid__25 and l__root_part__26 then
		l__humanoid__25:MoveTo(l__root_part__26.Position);
	end;
end;
function M.IsMoving(p31)
	return p31.__update_cnnt ~= nil;
end;
local u6 = l__CommonOHOH__1.load.OHOHConnection();
function M.AddHandleOnMoveOver(p32, p33, ...)
	u1.AddHandleOnMoveOver(p32, p33, ...);
	return u6.new(p32, u1.DelhandleOnMoveOver, u1.OnMoveOverHandleExist, p33);
end;
return M;
